package com.elong.android.specialhouse;

import android.content.Context;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class IConfig {

	/**
	 * 1:log写到本地/data/data/com.dp.android.elong/crashlog.txt
	 * 2:log发送到server
	 * 3:log写到logcat
	 */
	public final static int WRITE_LOG_TO_WHERE = 3;

	public final static boolean DEBUG_ON = false ;
	public final static boolean CLICKABLE_MONKEY_ADS = true;

	public final static boolean MANAGE_ACTIVITYSTACK_MANUALLY = true;

	// 自动化测试开关
	public final static boolean AUTO_TEST_ON = false;
	// Countly数据收集开关
	public final static boolean COUNTLY_ON = true;

	public final static boolean COMPRESS_NETWORK_DATA = true;

	public final static int APARTMENT_CHECKIN_CHECKOUT_DAYS = 7;

	/**
	 * 网络超时时间
	 */
	public final static int NETWORK_TIMEOUT = 15000;

	// JAVA API 默认压缩算法
	public final static String COMPRESS_GZIP = "gzip";
	public final static String COMPRESS_LZSS = "lzss";
	public static String DEFAULT_COMPRESS = COMPRESS_GZIP;

	public final static long CITY_DISTRICTDATA_UPDATEPERIOD = 10 * 60 * 1000;

	public final static long CITY_FILTERDATA_UPDATEPERIOD = 10 * 60 * 1000;

	public final static long GROUPON_CITY_DISTRICTDATA_UPDATEPERIOD = 2 * 24 * 60 * 60 * 1000;

	// 屏幕无效点击事件判断阀值,单位:ms
	public final static int SCREEN_RELEASE_TIME = 500;

	//网络环境配置
	public static final String KEY_MAPI_ROOT_URL = "MAPI_ROOT_URL";
	public static final String KEY_PAYMENT_ROOT_URL = "PAYMENT_ROOT_URL" ;
	public static final String KEY_IMG_UPLOAD_ROOT_URL = "IMG_UPLOAD_ROOT_URL";

	public static String MAPI_ROOT_URL = "http://10.35.45.84/";
	public static String PAYMENT_ROOT_URL = "http://10.35.45.84/";
	public static String IMG_UPLOAD_ROOT_URL = "http://10.35.45.84/";

	public static void initServerUrl(Context context ,int resId) {
		Properties serverProp = loadServerProp(context ,resId);
		MAPI_ROOT_URL = serverProp.getProperty(KEY_MAPI_ROOT_URL);
		PAYMENT_ROOT_URL = serverProp.getProperty(KEY_PAYMENT_ROOT_URL);
		IMG_UPLOAD_ROOT_URL = serverProp.getProperty(KEY_IMG_UPLOAD_ROOT_URL);
	}

	private static Properties loadServerProp(Context context ,int resId) {
		Properties serverProperties = new Properties( ) ;
		InputStream file = context.getResources().openRawResource(resId);
		try {
			serverProperties.load(file);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return serverProperties ;
	}
}